All Questions
8 questions
1vote
2answers
940views
Replace several consecutive lines with a single line using sed
In all my python scripts, I'd like to replace the 2 consecutive lines import matplotlib as mpl mpl.style.use(mpl_plt_default_template) with just the line plt.style.use(mpl_plt_default_template) So ...
1vote
1answer
246views
preg_replace for replacing comment text in a file
In a file, I want to replace COMMENT AS `<some_comment>` with COMMENT '<some_comment>' That is, replace COMMENT AS with just COMMENT, and replace the backticks around the following ...
1vote
2answers
2kviews
Bash replace string with command
I have a command (logcat) which outputs a long log like this: 07-27 09:26:22.416 17574 17886 D SurfaceControl: Excessive delay in setPowerMode() 07-27 09:26:22.421 17574 17599 I PowerManagerService: ...
0votes
2answers
50views
Replacing string with other string
In line((s) that originate from csv file) 14/Feb/2016:15:21:33-0500]http://map1.link.de/mk what is the easiest part to replace/delete&add ]http://map1.link.de/ with , having in mind that after ...
1vote
1answer
1kviews
Replacing mysql settings with sed
I am creating a backup web server but I want the backup server to only have one root user. So after moving all the databases I need to replace all the mysqli_connect(...) lines in db.txt. I have ...
5votes
3answers
4kviews
Search and replace strings that are not substrings of other strings
I have a list of replacements like so: search_and -> replace big_boy -> bb little_boy -> lb good_dog -> gd ... I need to make replacements for the above, but at the same time avoid ...
3votes
5answers
6kviews
Replace text between brackets
I'm using awk '{ gsub(/BAR|WIBBLE/, "FOO"); print }' to replace text in data like: SOMETHING [BAR, WIBBLE] SOMETHING [BAR] This gives the desired result of: SOMETHING [FOO, FOO] SOMETHING [FOO] But ...
3votes
1answer
688views
How to join vCards lines
vCard uses a special way to split long lines: At 75 characters, insert a DOS newline and a space. Joining therefore means to replace all occurrences of the sequence "CR, LF, space" with an empty ...